Skip to content

samples(StorageControl): Add sample for anywhereCache #2143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 11, 2025

Conversation

thiyaguk09
Copy link
Contributor

@thiyaguk09 thiyaguk09 commented Jul 3, 2025

This PR adds sample code for the anywhere cache feature, allowing users to:

  • Create anywhere cache
  • Get anywhere cache
  • List anywhere cache
  • Update anywhere cache
  • Pause anywhere cache
  • Disable anywhere cache
  • Resume anywhere cache

@thiyaguk09 thiyaguk09 requested review from a team as code owners July 3, 2025 09:59
Copy link

snippet-bot bot commented Jul 3, 2025

Here is the summary of changes.

You are about to add 7 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jul 3, 2025
@thiyaguk09 thiyaguk09 changed the title Feat(StorageControl): Add sample for anywhereCache feat(StorageControl): Add sample for anywhereCache Jul 8, 2025
@danielduhh danielduhh requested a review from a team July 8, 2025 06:00
@bajajneha27 bajajneha27 requested a review from bshaffer July 8, 2025 06:12
@thiyaguk09
Copy link
Contributor Author

@bshaffer Just a reminder—when you have time, please take a look at this PR.

Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These samples look good, but it would be nice if we had some basic testing around them!

@thiyaguk09
Copy link
Contributor Author

These samples look good, but it would be nice if we had some basic testing around them!

Anywhere cache creation is a long-running operation, the test was not added for all languages as discussed.

@thiyaguk09 thiyaguk09 requested a review from bshaffer July 30, 2025 08:58
// completes.
$response = $storageControlClient->createAnywhereCache($request);

printf('Created anywhere cache: %s', $response->getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these responses are operations (because they are longrunning), so this is incorrect.

I would suggest either calling the $response variable an $operation, or waiting for it to complete like this:

$operation->pollUntilComplete();
$cache = $operation->getResult();

printf('Created anywhere cache: %s', $cache->getName());

Copy link
Contributor Author

@thiyaguk09 thiyaguk09 Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retrieve the cache name using the operation pollUntilComplete method.

   $operation = $storageControlClient->createAnywhereCache($request);
   $operation->pollUntilComplete([
       'totalPollTimeoutMillis' => 5400000,
       'initialPollDelayMillis' => 1000, // Start with 1 second delay
       'pollDelayMultiplier' => 2,      // Double delay each time
       'maxPollDelayMillis' => 60000,   // Max 60 seconds delay between polls
   ]);

   /** @var AnywhereCache $anywhereCacheResult */
   $anywhereCacheResult = $operation->getResult();
   printf('Created anywhere cache: %s' . PHP_EOL, $anywhereCacheResult->getName());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess would be the only required configuration of the above is totalPollTimeoutMillis, but the others may be nice to have there as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bshaffer I hope the test cases are working well. Is it okay to approve them, or do we need to add more?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran these tests and they all passed. Great job!

@thiyaguk09 thiyaguk09 requested a review from bshaffer August 5, 2025 13:24
@bajajneha27 bajajneha27 changed the title feat(StorageControl): Add sample for anywhereCache samples(StorageControl): Add sample for anywhereCache Aug 8, 2025
@bshaffer bshaffer merged commit fb4e5fc into GoogleCloudPlatform:main Aug 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants